package com.erp.module.faHuoDanJu.faHuo2

import android.content.Context
import android.util.Log
import com.erp.bean.FaHuoBean
import com.erp.Interface.OnUserDataInterface
import com.erp.util.Myutil
import com.erp.module.faHuoDanJu.AddFaHuoModel

/**
 * Created by Administrator on 2018/11/12/012.
 * 作者：刘洋
 */
class IAddFaHuoKP(val context : Context, val KView : AddFaHuoKView, val car_numble : String, val shop_name : String, val type:Int): AddFaHuoKP {

    val modle = AddFaHuoModel()
    override fun AddPhoto(list: List<FaHuoBean.photo>, deletelist: List<FaHuoBean.photo>) {
        if(!isadd(list)&& deletelist.isEmpty()){
            Myutil.MyTost("不能未做任何操作上传")
            KView.AddPhotoNo()
            return
        }
        modle.addFaHuo(context,car_numble,shop_name,list,deletelist,type,object : OnUserDataInterface {
            override fun onUserData(data: String?) {
                Log.d("AddPhoto",data)
                KView.AddPhotoOK()
            }

            override fun onNot(throwable: String?) {
                Log.d("AddPhoto",throwable)
                KView.AddPhotoNo()
            }
        })
    }
    fun isadd(list: List<FaHuoBean.photo>) : Boolean{
        var b = false
        for(i  in 0 until list.size){
            if(list.get(i).fid==""){
                b=true
            }
        }
        return b
    }
}